<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>删除零</title>
    </head>
    <body>
        <p>3,0,6,8,7,2,0,0,9,0,3,1,0</p>
        <p id="a1"></p>
        <p id="a2"></p>
        <p id="a3"></p>
        <script>
            let arr = [3,0,6,8,7,2,0,0,9,0,3,1,0];
            //one
            let arr_1 = [];
            for(let i = 0;i<13;++i)
                if(arr[i]!==0) arr_1.push(arr[i]);
            let str = arr_1[0];
            for(let i = 1;i<arr_1.length;++i)
                str += ','+arr_1[i];
            document.getElementById("a1").innerHTML="第一种方案排序结果："+str;
            //two
            let arr_2 = [],st = 0;
            for(let i = 0;i<13;++i) arr_2[i] = arr[i];
            while(st<=arr_2.length){
                if(arr_2[st]===0) arr_2.splice(st,1);
                else ++st;
            }
            str = arr_2[0];
            for(let i = 1;i<arr_2.length;++i)
                str += ','+arr_2[i];
            document.getElementById("a2").innerHTML="第二种方案排序结果："+str;
            //three
            let arr_3 = [];
            for(let i = 0;i<13;++i) arr_3[i] = arr[i];
            st = 0;
            while(st<=arr_3.length) {
                if (arr_3[st] === 0) delete arr_3[st];
                ++st;
            }
            str = "";
            let i = 0;
            for(;i<arr_3.length;++i)
                if(arr_3[i]!==undefined){
                    str = arr_3[i];
                    ++i;
                    break;
                }
            for(;i<arr_3.length;++i)
                if(arr_3[i]!==undefined) str+= ','+arr_3[i];
            document.getElementById("a3").innerHTML="第三种方案排序结果："+str;
        </script>
    </body>
</html>